import pygame


# 常量基类
class BaseConstant:

    @classmethod
    def __iter__(cls):
        constants = [
            value for name, value in cls.__dict__.items()
            if not name.startswith('__') and not callable(value)
        ]
        return iter(constants)

    @classmethod
    def __getitem__(cls, position):
        constants = [
            value for name, value in cls.__dict__.items()
            if not name.startswith('__') and not callable(value)
        ]
        return constants[position]

    @classmethod
    def __len__(cls):
        constants = [
            value for name, value in cls.__dict__.items()
            if not name.startswith('__') and not callable(value)
        ]
        return len(constants)


# 物体朝向常量类
class Direction(BaseConstant):
    UP = (0, -1)
    DOWN = (0, 1)
    LEFT = (-1, 0)
    RIGHT = (1, 0)


# 玩家常量类
class Player:
    PLAYER1 = 1
    PLAYER2 = 2


# 敌方坦克出生点常量类
class EnemyTankSpawn(BaseConstant):
    """
    实际值表示的是出生点坐标对象
    """
    LEFT_RECT = pygame.Rect(3 + 6 * 48, 3, 48, 48)
    MIDDLE_RECT = pygame.Rect(3 + 12 * 48, 3, 48, 48)
    RIGHT_RECT = pygame.Rect(3, 3, 48, 48)


# 敌方坦克类型
class EnemyTankType:
    ENEMY_01 = 1
    ENEMY_02 = 2
    ENEMY_03 = 3
    ENEMY_04 = 4
    ENEMY_PROP = 5


# 爆炸类型
class ExplosionType:
    # 小型爆炸，当子弹接触地图边界、有碰撞体积的地形块、子弹和坦克时发生
    SMALL = 0
    # 大型爆炸，当子弹摧毁坦克或基地时发生
    LARGE = 1


# 游戏界面常量
class GameScreen:
    # TODO 增加游戏主界面
    MAIN_MENU = 0
    # 游戏过场界面
    TRANSITION = 1
    # 正在游戏中界面
    IN_GAME = 2
    # 游戏结算界面
    RESULTS = 4
    # 游戏失败界面
    FAIL = 5
    # 游戏结束界面
    END = 6
